home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 005 / epistat.arc / SAMPLSIZ.BAS (.txt) < prev    next >
Encoding:
GW-BASIC  |  1983-10-18  |  3.6 KB  |  58 lines

  1. 1  REM                 CALCULATING SAMPLE SIZES
  2. 2  REM             Written by Tracy L. Gustafson, M.D.
  3. 3  REM            Round Rock, Texas. Version 2.1, 1983
  4. 4  DEF SEG=&H40
  5. 5  A=PEEK(&H17): IF NOT(A AND &H20) THEN POKE &H17,(A AND (NOT &H20)) OR &H20
  6. 6  DEF SEG: KEY OFF: SCREEN 0,0: WIDTH 80: COLOR 7,0,1
  7. 7  CLEAR: DEFINT A-C,N,T,Z: DEFSTR D
  8. 10  CLS: PRINT TAB(22);"KEY";STRING$(26,205);"CLOSE"
  9. 12  PRINT TAB(22);"OPEN CALCULATING SAMPLE SIZES OPEN"
  10. 15  PRINT TAB(22);"SCREEN";STRING$(26,205);"LOAD": PRINT: PRINT: PRINT: AF=0
  11. 20  PRINT TAB(18);"1.)  For a population survey": PRINT
  12. 30  PRINT TAB(18);"2.)  For a paired case-control study": PRINT
  13. 40  PRINT TAB(18);"3.)  For an unpaired case-control study": PRINT: PRINT
  14. 50  PRINT TAB(25);: INPUT "Enter your selection:  ",ASUB
  15. 60  IF ABS(ASUB-2)>1.1 THEN BEEP: GOTO 50
  16. 70  CLS: ON ASUB GOTO 80,190,200
  17. 80  PRINT TAB(22);"SAMPLE SIZE FOR POPULATION SURVEY": PRINT TAB(22);STRING$(33,205): PRINT
  18. 85  PRINT "  HOW LARGE is the population from which you want to select your sample?":PRINT TAB(24);:INPUT "(you may approximate)  ",PS: PRINT
  19. 90  PRINT " Enter your best estimate of the POPULATION RATE of the survey characteristic:": PRINT TAB(23);:INPUT "(err towards 50%)      Percent = ",P
  20. 100  PRINT :PRINT "   What is the MAXIMUM DIFFERENCE between the true population rate and"
  21. 110  PRINT TAB(10);: INPUT "your sample rate that you can tolerate?     Percent = ",XD: PRINT
  22. 120  PRINT " How certain must you be that the difference between the true population rate": PRINT TAB(25);"and your sample rate is <";XD;"% ?"
  23. 130  PRINT TAB(22);: INPUT "1) 90%   2) 95%   3) 99%   4) 99.9%          ",C
  24. 140  IF C=1 THEN XZA=1.645 ELSE IF C=2 THEN XZA=1.96 ELSE IF C=3 THEN XZA=2.575  ELSE IF C=4 THEN XZA=3.29 ELSE IF C>4 THEN BEEP: GOTO 120
  25. 150  P=P/100: XD=XD/100: SN=XZA*XZA*P*(1-P)/(XD*XD)
  26. 160  IF SN>PS/10 THEN SN=SN/(1+SN/PS)
  27. 170  PLAY "MB T180 L32 O2 EG#BG#E O4 EG#BG#E O3 EG#BG#E O2 L7 BG# L3 E."
  28. 175  PRINT: PRINT: COLOR 0,7: PRINT TAB(23);
  29. 180  PRINT "The SAMPLE SIZE required is ";INT(SN);TAB(80): COLOR 7,0
  30. 185  PRINT: GOTO 400
  31. 190  PRINT TAB(16);"SAMPLE SIZE FOR PAIRED CASE-CONTROL STUDY": PRINT TAB(16);STRING$(41,205): PRINT: GOTO 205
  32. 200  AF=1: PRINT TAB(15);"SAMPLE SIZE FOR UNPAIRED CASE-CONTROL STUDY": PRINT TAB(15);STRING$(43,205): PRINT
  33. 205  PRINT " Enter your best estimate of the POPULATION RATE of the study characteristic:": PRINT TAB(15);: INPUT "(err towards 50%)       Percent = ",P: PRINT
  34. 210  PRINT TAB(10); "Do you expect the test group rate to be HIGHER or LOWER":PRINT TAB(20);:INPUT "than the control group rate? (H or L)  ",A$: PRINT
  35. 220  IF A$="h" OR A$="H" OR A$="l" OR A$="L" THEN 230 ELSE BEEP: GOTO 210
  36. 230  PRINT "    What is the SMALLEST DIFFERENCE between the test group and controls":PRINT TAB(10);:INPUT "that you want to be able to detect?    Percent = ",XD
  37. 240  IF A$="h" OR A$="H" THEN PT=P+XD ELSE PT=P-XD
  38. 250  PRINT:PRINT "  How certain do you want to be that you detect a difference as small as";XD;"% ":PRINT TAB(30);"(if it exists) ?": PRINT TAB(20);
  39. 260  INPUT "1) 90%   2) 95%   3) 99%   4) 99.9%            ",C: PRINT
  40. 270  IF C=1 THEN XZB= -1.282 ELSE IF C=2 THEN XZB= -1.645 ELSE IF C=3 THEN XZB=  -2.327 ELSE IF C=4 THEN XZB= -3.08 ELSE IF C>4 THEN BEEP: GOTO 250
  41. 280  PRINT "  How certain do you want to be that any difference between your samples": PRINT TAB(14);
  42. 290  PRINT "that you may detect is not simply due to chance?":PRINT TAB(20);
  43. 300  INPUT "1) 90%   2) 95%   3) 99%   4) 99.9%            ",C
  44. 310  IF C=1 THEN XZA=1.645 ELSE IF C=2 THEN XZA=1.96 ELSE IF C=3 THEN XZA=2.575  ELSE IF C=4 THEN XZA=3.29 ELSE IF C>4 THEN BEEP: GOTO 280
  45. 320  P=P/100: XD=XD/100: PT=PT/100: PRINT :PRINT
  46. 330  IF AF=1 THEN 370
  47. 340  SN=(XZA*SQR(P*(1-P))-XZB*SQR(PT*(1-PT)))/XD : SN=SN*SN
  48. 345  PLAY "MB T180 L32 O2 EG#BG#E O4 EG#BG#E O3 EG#BG#E O2 L7 BG# L3 E."
  49. 350  COLOR 0,7: PRINT TAB(19);"The number of PAIRS required is: "; INT(SN); TAB(80): COLOR 7,0
  50. 360  GOTO 400
  51. 370  SN=(XZA*SQR(2*P*(1-P))-XZB*SQR(PT*(1-PT)+P*(1-P)))/XD: SN=SN*SN
  52. 375  PLAY "MB T180 L32 O2 EG#BG#E O4 EG#BG#E O3 EG#BG#E O2 L7 BG# L3 E."
  53. 380  COLOR 0,7: PRINT TAB(17);"The number required in EACH group is: ";INT(SN); TAB(80): COLOR 7,0
  54. 400  PRINT :PRINT: PRINT TAB(10);
  55. 405  INPUT "Do you want to calculate another SAMPLE SIZE? (Y or N)   ",A$
  56. 410  IF A$="Y" OR A$="y" THEN CLS: GOTO 10
  57. 420  END
  58.